import {
  ADD_COUNTER, ADD_GOODS
} from "./mutations_type"

export const mutations = {
  // addgoods(state, payload) {
  //   //每一个mutations方法完成的事件比较单一
  //   // for (let item of state.carList) {
  //   //   let product = null;
  //   //   if (item.id == payload.id) { //每次添加进行判断    是否存在这个商品    
  //   //     product = item;
  //   //   }
  //   // }
  // },
  [ADD_COUNTER](state, payload) {
    payload.count += 1;
  },
  [ADD_GOODS](state, payload) {
    payload.checked = false
    state.carList.push(payload)
  },
  addcategorylist(state, payload) {
    state.categorylist[payload.index] = payload.categorylist
    // state.categorylist.push(payload);
  },
  addrecommend(state, payload) {
    console.log(payload)
    state.recommend.push(payload);
  }
}